/**
 * LockState.java 
 * Copyright © 2014-2016, 杭州泊享网络科技有限公司
 * 
 * @author Liu Tao
 * @create 2015年5月8日
 */
package com.pshare.artemis.order.enums;

import java.util.HashMap;
import java.util.Map;

/**
 * 订单是否过时
 */
public enum OverdueState {

	NO(1, "未过期"), YES(0, "过期");

	private int code;
	private String name;

	private OverdueState(int code, String name) {
		this.code = code;
		this.name = name;
	}

	public int getCode() {
		return code;
	}

	public void setCode(int code) {
		this.code = code;
	}

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public static Boolean codeOf(int code) {
		for (OverdueState em : OverdueState.values()) {
			if (em.getCode() == code) {
				return true;
			}
		}
		return false;
	}

	public static String getName(Integer code) {
		if (code == null) {
			return "";
		}
		for (OverdueState em : OverdueState.values()) {
			if (em.getCode() == code) {
				return em.getName();
			}
		}
		return "";
	}

	public static OverdueState get(Integer code) {
		for (OverdueState em : OverdueState.values()) {
			if (em.getCode() == code) {
				return em;
			}
		}
		return null;
	}

	public static Map<Integer, String> getAll() {
		Map<Integer, String> map = new HashMap<Integer, String>();
		for (OverdueState em : OverdueState.values()) {
			Integer code = em.getCode();
			map.put(code, em.getName(code));
		}
		return map;
	}

}
